<template>
  <div style="background: #f0f2f5; margin-top: -20px; height: 100%">
    <div class="wscn-http404">
      <!-- <div class="pic-404"></div> -->
      <div class="bullshit">
        <div class="bullshit__headline">403</div>
        <div class="bullshit__headline">{{ message }}</div>
        <div class="bullshit__info">对不起，请登录后再尝试。</div>
        <div @click="backToHome" class="bullshit__return-home">返回登录</div>
        <!-- <a
          @click="backTopro"
          class="bullshit__return-home"
          style="margin-left: 1rem"
          >返回主页</a
        > -->
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useUserStore } from '@/stores'
import { useRouter } from 'vue-router'
const userStore = useUserStore()
const router = useRouter()
const { setUserName, removeRole, removeToken, removeUser } = userStore
// eslint-disable-next-line no-unused-vars
function loginOut() {
  // 清除本地的数据 (token + user信息)
  removeToken()
  removeRole()
  removeUser()
  router.removeRoute('Home') // 移除动态路由
  setUserName('未登录')
}
function backToHome() {
  loginOut()
  router.push('/login').catch(() => {})
}
// eslint-disable-next-line no-unused-vars
function backTopro() {
  loginOut()
  router.push('/').catch(() => {})
}
// 计算属性
const message = computed(() => '您的登录已过期，请重新登录！')
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.wscn-http404 {
  position: relative;
  width: 100%;
  // margin: 20px auto 60px;
  // padding: 0 100px;
  overflow: hidden;
  .pic-404 {
    position: relative;
    float: left;
    width: 600px;
    padding: 100px 0;
    overflow: hidden;
    &__parent {
      width: 100%;
    }
    &__child {
      position: absolute;
      &.left {
        width: 80px;
        top: 17px;
        left: 220px;
        opacity: 0;
        animation-name: cloudLeft;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-fill-mode: forwards;
        animation-delay: 1s;
      }
      &.mid {
        width: 46px;
        top: 10px;
        left: 420px;
        opacity: 0;
        animation-name: cloudMid;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-fill-mode: forwards;
        animation-delay: 1.2s;
      }
      &.right {
        width: 62px;
        top: 100px;
        left: 500px;
        opacity: 0;
        animation-name: cloudRight;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-fill-mode: forwards;
        animation-delay: 1s;
      }
      @keyframes cloudLeft {
        0% {
          top: 17px;
          left: 220px;
          opacity: 0;
        }
        20% {
          top: 33px;
          left: 188px;
          opacity: 1;
        }
        80% {
          top: 81px;
          left: 92px;
          opacity: 1;
        }
        100% {
          top: 97px;
          left: 60px;
          opacity: 0;
        }
      }
      @keyframes cloudMid {
        0% {
          top: 10px;
          left: 420px;
          opacity: 0;
        }
        20% {
          top: 40px;
          left: 360px;
          opacity: 1;
        }
        70% {
          top: 130px;
          left: 180px;
          opacity: 1;
        }
        100% {
          top: 160px;
          left: 120px;
          opacity: 0;
        }
      }
      @keyframes cloudRight {
        0% {
          top: 100px;
          left: 500px;
          opacity: 0;
        }
        20% {
          top: 120px;
          left: 460px;
          opacity: 1;
        }
        80% {
          top: 180px;
          left: 340px;
          opacity: 1;
        }
        100% {
          top: 200px;
          left: 300px;
          opacity: 0;
        }
      }
    }
  }
  .bullshit {
    position: relative;
    // float: left;
    margin-left: 30%;
    width: 50%;
    padding: 15% 0;
    overflow: hidden;
    &__oops {
      font-size: 1.5rem;
      font-weight: bold;
      line-height: 1.6rem;
      color: #1482f0;
      opacity: 0;
      margin-bottom: 20%;
      animation-name: slideUp;
      animation-duration: 0.5s;
      animation-fill-mode: forwards;
    }
    &__headline {
      font-size: 3rem;
      line-height: 5rem;
      color: #1482f0;
      opacity: 0;
      margin-bottom: 10px;
      animation-name: slideUp;
      animation-duration: 0.5s;
      animation-delay: 0.1s;
      animation-fill-mode: forwards;
    }
    &__info {
      font-size: 2rem;
      line-height: 4rem;
      color: grey;
      opacity: 0;
      margin-bottom: 10%;
      animation-name: slideUp;
      animation-duration: 0.5s;
      animation-delay: 0.2s;
      animation-fill-mode: forwards;
    }
    &__return-home {
      display: block;
      float: left;
      width: 15vw;
      height: 6vh;
      background: #1482f0;
      border-radius: 6rem;
      text-align: center;
      color: #ffffff;
      opacity: 0;
      font-size: 1.5rem;
      line-height: 6vh;
      cursor: pointer;
      animation-name: slideUp;
      animation-duration: 0.5s;
      animation-delay: 0.3s;
      animation-fill-mode: forwards;
    }
    @keyframes slideUp {
      0% {
        transform: translateY(60px);
        opacity: 0;
      }
      100% {
        transform: translateY(0);
        opacity: 1;
      }
    }
  }
}
</style>
